bitkeeper revision 1.551 (3fa639b1Ozv5gqMWisVgyFIergU8DQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 3 Nov 2003 11:19:13 +0000 (11:19 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 3 Nov 2003 11:19:13 +0000 (11:19 +0000)
hypervisor.h, dom0_ops.h, dom0_ops.c, dom0_defs.h:
  Add a version number to the dom0_op interface, to prevent crashes and hangs with out-of-date user tools.

tools/internal/dom0_defs.h
xen/common/dom0_ops.c
xen/include/hypervisor-ifs/dom0_ops.h
xenolinux-2.4.22-sparse/include/asm-xeno/hypervisor.h

index 1c271534ec2cca518b87ca66607c555813922cd5..bea8981bee44ea90f2f07b02b86af742b33b0564 100644 (file)
@@ -85,6 +85,8 @@ static inline int do_dom0_op(dom0_op_t *op)
     int ret = -1;
     privcmd_hypercall_t hypercall;
 
+    op->interface_version = DOM0_INTERFACE_VERSION;
+
     hypercall.op     = __HYPERVISOR_dom0_op;
     hypercall.arg[0] = (unsigned long)op;
 
@@ -95,7 +97,12 @@ static inline int do_dom0_op(dom0_op_t *op)
     }
 
     if ( do_xen_hypercall(&hypercall) < 0 )
+    {
+        if ( errno == EINVAL )
+            fprintf(stderr, "Dom0 operation failed -- need to"
+                    " rebuild the user-space tool set?\n");
         goto out2;
+    }
 
     ret = 0;
 
index 5358f19b502269874e9a35e06aa7a8961d9d19bc..17dbf1d4de896f620d4694080918f6aa97d500ec 100644 (file)
@@ -92,6 +92,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     if ( copy_from_user(&op, u_dom0_op, sizeof(op)) )
         return -EFAULT;
 
+    if ( op.interface_version != DOM0_INTERFACE_VERSION )
+        return -EINVAL;
+
     switch ( op.cmd )
     {
 
index 639860dd8bd42b47cc4bf8322a45a52ef35812b8..ff07461f8bf367546ace15f692261a51d1abe2dc 100644 (file)
 
 #include "hypervisor-if.h"
 
+/*
+ * Make sure you increment the interface version whenever you modify this file!
+ * This makes sure that old versions of dom0 tools will stop working in a
+ * well-defined way (rather than crashing the machine, for instance).
+ */
+#define DOM0_INTERFACE_VERSION   0xAAAA0001
+
 
 /*
  * The following is all CPU context. Note that the i387_ctxt block is filled 
@@ -178,6 +185,7 @@ typedef struct dom0_settime_st
 typedef struct dom0_op_st
 {
     unsigned long cmd;
+    unsigned long interface_version; /* DOM0_INTERFACE_VERSION */
     union
     {
         dom0_createdomain_t     createdomain;
index 9450f76f3c0213538ab38e863ef8d7636866d3de..fedd5d9455543a98e647e41568d640af9f0b972c 100644 (file)
@@ -265,6 +265,7 @@ static inline int HYPERVISOR_exit(void)
 static inline int HYPERVISOR_dom0_op(void *dom0_op)
 {
     int ret;
+    op->interface_version = DOM0_INTERFACE_VERSION;
     __asm__ __volatile__ (
         TRAP_INSTR
         : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),